<?php
namespace think;

//header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, system-admin-id, system-admin-token, agent-id, agent-token,cookie");
header('Access-Control-Allow-Credentials:true');

//以下为开发环境下的允许跨域源列表
$allow_origin = array(
    'http://localhost:1000',
    'http://localhost:8080',
    'http://localhost:8081',
    'http://192.168.1.7:1000',
    'http://192.168.1.4:1000',
    'http://localhost:15544'
);
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
if(in_array($origin, $allow_origin)){
    header('Access-Control-Allow-Origin:'.$origin);
}

$get_loaded_extensions=get_loaded_extensions();//获取PHP所有扩展
// if(!in_array('SourceGuardian',$get_loaded_extensions)){
  //  exit(json_encode(['code'=>-1,'msg'=>'当前PHP版本为'.PHP_VERSION.'检测到未安装SG11扩展，运行本系统必须安装该扩展，请先安装PHP扩展，SG11扩展全名为SourceGuardian(在Windows里可能叫SG12)'],JSON_UNESCAPED_UNICODE));
//}
if(!version_compare(PHP_VERSION, '7.2.0', '>')){
    exit(json_encode(['code'=>-1,'msg'=>'需要PHP版本>=7.2才能运行,当前PHP版本为'.PHP_VERSION],JSON_UNESCAPED_UNICODE));
}


// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';

// 支持事先使用静态方法设置Request对象和Config对象

// 执行应用并响应
Container::get('app')->run()->send();
